Ray Tracing System Architectures and Methods

ABSTRACT

Aspects comprise systems implementing 3-D graphics processing functionality in a multiprocessing system. Control flow structures are used in scheduling instances of computation in the multiporcessing system, where different points in the control flow structure serve as points where deferral of some instances of computation can be performed in favor of scheduling other instances of computation. In some examples, the control flow structure identifies particular tasks, such as intersection testing of a particular portion of an acceleration structure, and a particular element of shading code. In some examples, the aspects are used in 3-D graphics processing systems that can perform ray tracing based rendering.

CROSS-REFERENCE TO RELATED APPLICATIONS

This application is a continuation of Ser. No. 13/610,651, filed on nowU.S. Pat. No. 8,619,079, issued on Dec. 31, 2013, which is acontinuation of U.S. patent application Ser. No. 13/229,566, filed onSep. 9, 2011, now U.S. Pat. No. 8,300,049, issued on Oct. 30, 2012,which is a continuation of U.S. patent application Ser. No. 12/555,766,filed on Sep. 8, 2009, now U.S. Pat. No. 8,018,457, which is acontinuation-in-part of U.S. patent application Ser. No. 12/408,478,filed on Mar. 20, 2009, now U.S. Pat. No. 7,830,379, which is acontinuation-in-part of U.S. patent application Ser. No. 11/856,612, nowU.S. Pat. No. 7,969,434, which was filed on Sep. 17, 2007, and claimspriority from and incorporates U.S. Prov. App. No. 60/826,201, entitled“Ray Tracing Enhancements for Graphical Rendering”, filed on Sep. 19,2006; U.S. patent application Ser. No. 12/555,766 also claims priorityfrom Prov. App. No. 61/229,258, filed on Jul. 28, 2009 and from Prov.App. No. 61/229,705, filed on Jul. 29, 2009, both entitled “Ray TracingSystem Architectures and Methods” and from Prov. App. No. 61/095,890,filed on Sep. 10, 2008 and from Prov. App. No. 61/038,731, filed on Mar.21, 2008; U.S. patent application Ser. No. 12/408,478 also claimspriority from U.S. provisional application no. 61/038,731, entitled“Coupling Ray Storage and Compute for Memory-Efficient Ray IntersectionTest Scaling”, filed on Mar. 21, 2008, and from U.S. Prov. App. No.61/095,890, entitled “Architectures for Parallelized IntersectionTesting and Shading for Ray-Tracing Rendering”, filed on Sep. 10, 2008;all applications referenced above are incorporated by reference in theirentirety, for all purposes, herein.

BACKGROUND Field

The following relates to rendering, using ray tracing, two-dimensionalrepresentations of three-dimensional scenes composed of shapes, and moreparticularly to systems, methods, and means for intersection testing ofrays in 3-D scenes.

Related Art

Rendering photo-realistic 2-D images from 3-D scene descriptions withray tracing is well-known in the computer graphics arts. Ray tracingusually involves obtaining a scene description composed of geometricshapes, which describe surfaces of structures in the scene, and can becalled primitives. A common primitive shape is a triangle.

Virtual rays of light are traced into the scene from a view point (“acamera”); each ray is issued to travel through a respective pixel of the2-D representation, on which that ray can have an effect. The rays aretested for intersection with scene primitives to identify a firstintersected primitive for each ray, if any.

After identifying an intersection for a given ray, a shader associatedwith that primitive determines what happens next. For example, if theprimitive is part of a mirror, then a reflection ray is issued todetermine whether light is hitting the intersected point from aluminaire, or in more complicated situations, subsurface reflection, andscattering can be modeled, which may cause issuance of different rays tobe intersected tested. By further example, if a surface of an objectwere rough, not smooth, then a shader for that object may issue rays tomodel a diffuse reflection on that surface. As such, finding anintersection between a ray and a primitive is a first step indetermining whether and what kind of light energy may reach a pixel byvirtue of a given ray, since what light is hitting that primitive stillneeds to be determined.

Thus, most conventional algorithms build a tree of rays in flight whenray tracing a scene, where the tree continues along each branch until itleaves the scene or hits a luminaire that does not issue new rays. Then,for those branches that hit light emissive objects, the branches arerolled up through the primitive intersections, determining along the waywhat effect each primitive intersection has on the light that hits it.Finally, a color and intensity of light for the originally issued cameraray can be determined and stored in the buffer.

Ray tracing can be naively parallelized by providing many processingresources that operate on different portions of pixels of a 2-D scene tobe rendered. However, simply providing more computation capability doesnot necessarily allow a suitable scaling of ray tracing speed andefficiency. One reason for this is that such parallelization does notaccount for how data composing the scene, or an acceleration structurethat increases tracing efficiency can be accessed in an efficientmanner. A variety of improvements to ray tracing architectures remain tobe provided.

BRIEF DESCRIPTION OF THE DRAWINGS

FIG. 1 depicts a simplistic toy scene with a camera emitting rays thatare intersection tested, and such intersections cause shaders toexecute, emitting further rays for intersection testing;

FIG. 2 depicts an example system architecture in which an intersectiontesting resource, a computation resource for executing shaders, andexamples of their interconnection are illustrated;

FIG. 3 depicts an example intersection testing architecture and controllogic for managing usage of the components thereof;

FIG. 4 depicts an example intersection testing architecture illustratingfurther details of how aspects of the above architectures can beimplemented;

FIG. 5 depicts an example of how intersection processing (shading) andintersection testing (tracing) can be abstracted for ray tracing usingray identifiers meaningful within the scope of shading, and carriedthrough ray tracing;

FIG. 6 depicts further details of an example architecture for providingray tracing functionality in a system;

FIG. 7 depicts an example organization of a packet that can be sent froma packet unit according to FIG. 6, and used by an arbiter to triggerintersection testing of rays that the packet identifies;

FIG. 8 depicts aspects of a tester that can be used in ray intersectiontesting, and which can be abstracted from its control by the arbiter ofFIG. 6;

FIG. 9 depicts an example ray intersection testing results processingflow that can be implemented in the packet unit depicted in FIG. 6;

FIGS. 10A and 10B depict aspects of an example where packets contain asurplus of ray identifiers for available ray intersection testerresources;

FIG. 11 depicts an example intersection tester architecture that can beused in disclosed examples;

FIG. 12 depicts an acceleration structure for describing further aspectsthat can be implemented in ray tracing architectures;

FIG. 13 depicts aspects of how collections maintained by packet unit canbe selected to be tested, under different conditions detectable by thepacket unit;

FIG. 14 depicts details of aspects relating to collecting intersectingrays by shader, or by intersected object, which is a componentimplementable in ray tracing architectures;

FIG. 15 depicts data flow aspects relating to collecting and shading ofcollected rays based on intersected object and more granular shadingcode components; and

FIG. 16 depicts components of a system that can be used in implementingray tracing aspects disclosed with respect to previous figures.

DETAILED DESCRIPTION

The following description is presented to enable a person of ordinaryskill in the art to make and use various aspects of the inventions.Descriptions of specific techniques, implementations and applicationsare provided only as examples. Various modifications to the examplesdescribed herein may be apparent to those skilled in the art, and thegeneral principles defined herein may be applied to other examples andapplications without departing from the scope of the invention.

For clarity in description, data for a certain type of object, e.g., aprimitive (e.g., coordinates for three vertices of a triangle) usuallyis described simply as the object itself, rather than referring to thedata for the object. For example, when referring to “a ray”, it is to beunderstood that data representative of that ray is referenced, as wellas the concept of the ray in the scene.

FIG. 1 illustrates a simplified scene setup, in which a 2-D plane 175 isdisposed between a camera 105 and a scene 150, comprising objects 110,115 and a light 120. A camera ray 130 is emitted from camera 105 (suchusing program code descriptive of behaviors of the camera). It isdetermined through intersection testing that ray 130 intersects object110. A ray 131 is emitted by a shader (e.g., program code and datadescribing behavior for an object or surface) associated with object110. For example, object 110 may have a mirrored surface, and as suchthe shader for it would generate ray 131 to test reflection at an anglethat ray 130 was incident on object 110. It then is determined that ray131 hits object 115. For simplicity, a shader associated with object 115is shown to have similar behavior to that of the shader for object 110,emitting a ray 132 to test whether light is incident on object 115 at anangle that could have traveled on the path of ray 131. Ray 132 isdetermined to intersect light 120.

The example of FIG. 1 was necessarily grossly simplified. Many factorsadding computational cost to a more realistic ray tracing scene includethat the resolution of the 2-D representation to be rendered can behigh, such as a full HD resolution of 1920×1080 pixels (over 2 millionpixels). Each pixel of the scene can have many rays emitted from thecamera that are associated with it. Thus, rendering such a scene caninvolve initially testing many millions of camera rays alone, followedby much higher numbers of rays that are emitted by shaders identifiedbased on object intersections with camera rays, and in turn rayssubsequently emitted by shaders.

Shaders can involve substantial computation and emission of further raysthat test various conditions. For example, shaders can perform diffuselighting tests, such as Monte Carlo diffuse lighting, which involvesemission of a number of rays to test ambient lighting conditions.Shaders may emit rays to test whether an intersection point is shadowedby another object for known light sources in the scene. Shaders also canmodel complex materials characteristics, such as subsurface scatteringfor skin, reflection, refraction, and so on. Each of these functions caninvolve emission of rays that need to be intersection tested in thescene. Thus, rendering a full HD high resolution 2-D representation of acomplex scene can involve intersection testing of hundreds of millionsor more rays.

Thus, for purposes herein, this example shows that a ray is tested forintersection in a scene. If it is found to intersect an object (e.g., aprimitive), then a shader associated with that object can be identifiedand executed. That shader can in turn emit more rays to be intersectiontested. The number and type of rays that shader emits typically dependsboth on characteristics of the intersecting ray and also on the effectsthat the shader is implementing.

With so many rays needing intersection testing, not all rays can beintersection tested concurrently. Also, considering the rendering of ascene progressing from start to finish, at any given time, not all raysthat need to be traced to complete the rendering have been defined,since scene rendering itself determines what rays will be tested.

FIG. 2 illustrates an example system 200 for use in rendering a scenewith ray tracing techniques. System 200 comprises a main memory 205, inwhich is stored data 206 for intersection shading (e.g., shader code,textures, procedural geometry, and so on), primitives and accelerationshape elements (e.g., triangles, triangle strips, vertexes, boundingspheres, axis aligned bounding box or k-d tree definitions, and so on),and a master copy of data 208 defining the rays currently being testedfor intersection in the scene. The main memory 205 communicates with anintersection processing resource 202, in which shaders for identifiedray/primitive intersections can be run. The communication between memory205 and intersection processing resource 202 is shown to include link221 for providing intersection shading data 206 from memory 205, andlink 222 for providing primitive data from memory 205.

The intersection processing resource 202 operates to shade intersectionsidentified by an intersection testing resource 210. Intersection testingresource 210 is directed to test rays by a controller 203. Controller203 provides indications of rays to be tested to intersection testingresource 210 via a link 225; preferably controller 203 indicates rays tobe tested by providing an identifier, which can be related to a memorylocation storing data defining that ray resident in cache 211. In thatpreferred situation, definition data for the rays to be tested isobtained/received via link 228 from ray definition cache 211.Intermediate testing results of a current closest detected primitiveintersection can be stored with ray definition data in cache 211 (i.e.,in some implementations, rays can intersect primitives, but if the raysare not tested in an order that the ray traverses the scene, then afarther intersection can be detected prior to a real, closestintersection, which is generally the only intersection of interest).

Closest possible detected intersections (if any) are indicated via alink 224 to controller 203 (e.g., if a ray did not intersect any sceneobject that that ray may or may not be indicated through link 224).Intersection testing resource 210 receives primitive and accelerationshape data from memory 205 through link 220.

Controller 203 arranges for processing of these possible closestindicated intersections in intersection processing resources 202.Controller 203 receives data defining rays to be intersection testedthat have been created by the shaders executing on resources 202. InFIG. 2, link 226 is depicted for receiving such new ray data, while link227 is depicted for providing information to instantiate shading of aparticular intersection that was provided from link 224. Link 227 cancomprise providing, or fetching code and data defining a shader, orotherwise directing intersection processing resources to perform suchfetching from memory 205.

Controller 203 also manages the master copy of ray definition data 208stored in memory 205, and can store data defining new rays in memory 205via link 223. Data stored in memory 205 defining rays that havecompleted intersection testing are replaced by data defining new raysinstantiated by the shaders.

The intersection testing resources 210 and the intersection processingresources 202 can be implemented on a processing platform 201 and cancomprise threads of processing on a multithreaded processor, or threadsexecuting on separate cores of a multiple core processor, or physicallyseparate processors, each potentially with multiple cores. Each threadcan execute instructions from computer executable code obtained frommemory 205 or from another source. Similarly, memory 205 may beimplemented as dynamic RAM accessible through a memory controller (notseparately depicted) by processor 201. Cache 211 may be implemented invarious levels, such as a private or semi-private L1 cache owned by oneor more cores in a multiple core processor, L2 caches and L3 that may beshared among cores and/or among processors. Preferably, ray definitiondata stored in cache 211 is protected from being overwritten by normalcache management algorithms, such as Least Recently Used, and the like.Instead, it is preferred that controller 203 manage the ray definitiondata stored in cache 211, as a subset of the ray definition data master208. Such ray definition data in cache 211 can be updated from master208 via link 229.

The links 220-229 illustrated may be implemented based on theimplementation of the cache 211, memory 205, and the intersectiontesting 210 and processing 210 resources.

Generally, intersection testing resource 210 performs morefixed-function types of computation, in that it tests rays forintersection against shapes, usually either a primitive shape or anacceleration shape element, which bounds a selection of primitivesdefining the scene. By contrast, the types of computation to beperformed during shading (on the intersection processing resource 202)is more general, in that shaders can perform a variety of computation,access, manipulate and create various data, and so on. Therefore, insome circumstances, intersection testing resources 210 can beimplemented beneficially with more fixed-function processing, whileresources 202 can often be implemented beneficially on a more generalpurpose computing platform. Therefore, in some circumstances,intersection testing resources 210 can be provided as an accelerationfunction, add-in card, co-processor, or the like that either isfixed-function or can be programmed with the expectation that theprogramming will not change often during the rendering of a scene.

Implementations according to this disclosure need not have allcharacteristics shown in example system 200. For example, in system 200,rays are indicated for intersection testing by providing rayidentifiers, separate from data defining the rays to intersectiontesting resource 210, which is optional. By further example, variouslinks where illustrated, but depending on the implementation, not allsuch links may be necessary or desired. Instead, FIG. 2 depicts a systemwherein computation resources can be provided for intersection testing,and they therefore produce indications of detected intersections. Theseintersection testing resources can operate concurrently with computationresources that are executing shaders for detected intersections. Theshaders emit new rays for intersection testing, which are taken up fortesting by the intersection testing resources.

FIG. 3 includes a block diagram of an example of an intersection testingresource 210 that includes a plurality of test cells 310 a-310 n and 340a-340 n. Acceleration structure elements are illustrated as beingsourced from storage 207 (elements of an acceleration structure can bedefined by definition data contained in a memory that also contains datadefining primitives of the scene.

ITU 303 also comprises collection management logic 303 and collectionbuffer 361. Collection buffer 361 and ray data 211 can be stored in amemory 340 that can receive ray data from memory 139 (for example).Collection buffer 361 maintains ray references associated with GADelements. Collection management 303 maintains those collections based onintersection information from test cells. Collection management 303 alsocan initiate the fetching of primitives and GAD elements from memory 207for testing ray collections.

ITU 303 returns indications of identified intersections, which can bebuffered in output buffer 375 for ultimate provision via resultsinterface 225 to intersection processing 202. Indications may compriseinformation sufficient to identify a ray and a shape, such as aprimitive, which the ray was determined, within a given degree ofprecision, to intersect. The degree of precision can include that agiven bounding element bounding one or more primitives was found to beintersected by one or more rays, but each primitive has not yet beenfinally intersection tested with such rays.

ITU 303 can be viewed as a function or a utility that can be calledthrough a control process or driver that provides ITU 303 with rays andgeometric shapes against which the rays would be tested forintersection. For example, ITU 303 can be fed information through adriver, which can be considered in one aspect to be a process thatinterfaces ITU 303 with other rendering processes, such as shading, andinitial ray generation functions. From the perspective of ITU 303, ITU303 need not be aware of the origin of the information provided to it,as it can perform intersection testing using the rays, GAD, andprimitives (or more generally, scene objects) provided to it, orobtained by it based on other information provided to it.

As described above, ITU 303 may control how, when, and what data isprovided to it, such that ITU 303 is not passive, and may for example,fetch ray or geometry data, or acceleration data as required forintersection testing. For example, ITU 303 may be provided with a largenumber of rays for intersection testing, along with informationsufficient to identify a scene in which the rays are to be tested. Forexample, ITU 303 may be provided more than ten thousand rays (10,000)rays for intersection testing at given time and as testing for thoserays complete, new rays (generated by intersection processing 202) maybe provided to keep the number of rays being processed in the ITU 303 atabout the initial number, as described below. ITU 303 may thereaftercontrol (in logic 303) temporary storage of the rays during processing(in ray collection buffer 361 (see FIG. 3)) and may also initiatefetching of primitives and elements of GAD as needed during theprocessing.

As described above, GAD elements and primitives are transient in ITU 303compared to rays, as ray identifiers are maintained in buffer 361 andorganized with respect to GAD elements, and data defining rays (ray data211) is also maintained for use by test cells 310 a-310 n and 340 a-340n. Each of buffer 361 and ray data 211 can be maintained in memory 340,which may be physically implemented in a variety of ways, such as one ormore banks of SRAM caches.

As introduced above, logic 303 tracks status for ray collections storedin memory 340, and determines which collections are ready forprocessing. As shown in FIG. 3, logic 303 is communicatively coupled tomemory 340, and can initiate delivery of rays for testing to each of theconnected test cells.

In examples where a particular GAD element may bound both other GADelements and primitives, ITU 303 can have datapath for providing bothGAD elements and primitives to each test cell, as well as rays, so thatlogic 303 can arrange for testing rays of collections among the testingresources. In such examples, because of the typical difference in shapebetween GAD elements and primitives (spheres versus triangles, forexample), an indication to switch test logic or load an intersectiontest algorithm optimized for the shape being tested may be provided fromlogic 303.

Logic 303 may directly or indirectly cause provision of information totest cells 310 a-310 n and test cells 340 a-340 n. In indirectsituations, logic 303 can provide information to each test cell so thateach test cell may initiate fetching of ray data for test from memory340. Although logic 303 is illustrated separately from memory 340, forsimplicity of description, logic 303 may be implemented within circuitryof memory 340, as management functionality performed by logic 303largely relates to data stored in memory 340.

An ability to increase parallelization of access to memory 340 byintersection test resources is an advantage of some aspects describedherein. As such, increasing a number of access ports to memory 340,preferably up to at least one per test cell is advantageous. Exampleorganizations related to such parallelization are further describedbelow.

Also, ITU 303 can operate asynchronously with respect to units thatprovide input data to it, or receive outputs from it. Here,“asynchronous” can include that the ITU may receive and beginintersection testing of additional rays while intersection testingcontinues for previously received rays. Also, “asynchronous” may includethat rays do not need to complete intersection testing in an order thatITU 303 received them. Asynchronous also includes that intersectiontesting resources in ITU 303 are available for assignment or schedulingof intersection testing without regard to position of a ray within a 3-Dscene, or a scheduling grid superimposed on the scene, or to test onlyrays having an intergenerational relationship, such as parent rays andchildren rays spawned from a small number of parent rays, or only raysof a specific generation—e.g., camera rays or secondary rays.

Output buffer 375 can receive indications of identified intersections ofprimitives and rays which possibly intersected the primitive. In anexample, the indications include an identification for a primitivepaired with an information sufficient to identify a ray that intersectedthe primitive. Identification information for a ray may include areference, such as an index, which identifies a particular ray in a listof rays. For example, the list may be maintained by driver running on ahost, and the list may be maintained in memory 205. Preferably, memory205 also includes ray definition data for all the rays in memory 340.However, the ray identification information may also includeinformation, such as the ray's origin and direction, sufficient toreconstruct the ray, if memory 205 does not contain such information.

FIG. 4 depicts aspects of an example architecture to which systems canbe designed and organized herein. The architecture depicted comprises aplurality of intersection testing resources (“intersection testers”) 405a-405 n each coupled with a respective cache 465 a-465 n, in which isstored respective ray definition data 466 a-466 n. Intersection testers405 a-405 n receive scene objects to be tested for intersection throughdata lines 460, which can be fed through a memory access initiated by acollection manager 475. The shapes can be stored in a memory (e.g., aqueue or a buffer) 440 to be made available to intersection testers 405a-405 n.

Intersection testers 405 a-405 n thus have local access to raydefinition data in respective memories, and are directed to obtain anduse portions of such ray definition data by receiving ray identifiersfrom respective input buffers 421 a-421 n. Input buffers 421 a-421 n canbe provided in or otherwise serviced by distribution logic 480 thatimplements decision points 413-415, in which a determination is madeconcerning whether a ray identifier provided from collection management475 should be added to any of input buffers 421 a-421 n.

Each intersection tester 405 a-405 n produces results that can beprovided to collection management 475 (as illustrated through resultschannels 450 a-450 n). In some examples, such results are processed bycollection management when the results are for intersections betweenrays and elements of an acceleration structure (i.e., GAD elements),while if the results are for intersections between primitives and rays,then those results can be outputted from or forwarded by collectionmanagement 475. Collection management 475 maintains assocations betweenthe ray IDs and the respective GAD element bounding objects to be testednext (and for which data is provided in buffer 440 accessible tointersection testers 405 a-405 n.

In some examples, buffer 440 is filled by DMA transactions initiated bycollection management 475 from a main memory (e.g., memory 205). Forexample, in a case of a hierarchical acceleration structure, buffer 440can be made to store shapes that are children of a parent accelerationelement, against which a collection of rays has been accummulated.Highest throughput is achieved when rays of a given collection areequally distributed among caches 466 a-466 n.

When multiple rays of a given collection are in one cache, then theother intersection testers can stall, or they can test rays from a nextcollection. Other aspects to note are that more than one ray ID for agiven ray collection can be stored in any of queues 421 a, 421 b, 421 c(shown by collection 447). In such cases, the ITR for that queue cantest both rays, and output results for the second test (or however manysubsequent tests) as they become available.

Where multiple rays for a given collection are tested in one of theintersection testers (e.g., intersection tester 405 b), the remainder ofresults for that collection can wait for all results of a collection tobe assembled, or the “straggler” result can be propagated as available,and while other tester is performed by the testers. In someimplementations, a maximum number of out of order tests can beaccommodated (or otherwise designed for) before collection testingsynchronization is again required, as described below.

In sum, FIG. 4 illustrates a system organization allowing a packet ofray identifiers associated with one or more shapes to be distributedinto queues for a plurality of testing resources, that each store asubset of ray data. Each test resource fetches ray data identified byeach ray identifier against a shape loaded to the test resource.Preferably, the shapes can be streamed sequentially through all the testresources concurrently. The shapes can be identified as a sequence ofchildren starting at an address in a main memory. Thus, FIG. 4illustrates a system organization where a shape generally is testedconcurrently against multiple rays.

FIG. 5 depicts a alternate perspective on the architectural aspectsdepicted in FIGS. 2-4, in conjunction with other functionality. Onehigh-level aspect of FIG. 5 is that intersection processing 202 maycommunicate with intersection testing 210 through an abstraction layer501. In some instances, of abstraction layer 501, shaders executing forintersection processing can instantiate new rays to be intersectiontested. Such new rays can be identified by identifiers meaningful withinthe context of the processing resources executing the shaders. Forconvenience, those identifiers are called “software identifiers” or “SWidentifiers”. These SW identifiers can be provided with definition datafor rays to be tested to a SW to HW ID mapper 515, which produces arespective identifier for each of those rays that can be used toidentify such rays during their intersection testing. The SW identifiersfor the rays can be stored with the ray definition data, and whenintersection results for a given ray are to be reported, the SWidentifier for that ray can be reported, along with intersectioninformation. The SW identifier can be identified for a particular HWidentifier using a HW ID to SW ID mapper 520. In other examples the SWID can be stored with ray definition data in RAM 211, and in otherexamples, the HW ID can be a subset of bits of the SW ID, or can bebased on an algorithmic transformation of the SW ID.

However, in the context of systems according to an architecture likethat of FIG. 4, it is preferred that the HW ray ID be selectable so thatintersection testing resources can have flexibility in determining whereto store ray definition data for a particular ray. This determinationcan be made to effect load balancing among separate memories storing raydefinition data. Independent ray identifier strategies according to thisexample allow ray identifiers to be sized appropriately for differentpurposes. For example, a master ray memory may be maintained, andsubsets of those rays may be actively intersection tested to completionin intersection testing 210. Thus, a number of rays in the master memorycan be many times larger than a number of rays actively being tested,making identifiers to uniquely identify each ray in the master memorylonger.

This ray identifier approach also provides an example architecturalchoice that accepts a larger total memory footprint for storing a givennumber of rays, in order to gain a benefit that total data movement torepetitively test a given ray for intersection is comparatively less.

Returning to FIG. 5, geometry and acceleration shape data 207 can beprovided to both intersection processing (e.g. shading) and intersectiontesting (i.e., acceleration structure traversal and/or primitiveintersection testing).

Results returned from intersection testing 210 to intersectionprocessing 202 can comprise indications of detected intersections ofrays against one or more of primitives and acceleration elements. Insome implementations, rays can be collected or otherwise buffered at anoutput of intersection testing (e.g., output buffer 375). Buffering canbe implemented in a variety of ways and can include that rays are sortedbased on a variety of common attributes. As previously explained, rayscan be collected into collections based on acceleration element, and italso was disclosed that acceleration elements can be made to bound aparticular scene object. In some examples then, the collection of rayscan be based on scene object. In some implementations, this collectionstrategy also can allow collection of rays to be executed against acommon shader.

As shown with respect to output buffer 375, buffering of rays can bemade to allow collections of rays to be executed against common shadingcode. Further, data elements to be used can be increased in locality bycollecting rays in output buffer 375 so that vertex attribute data 511,texture data 512, and/or uniform data 513 can be made available for agiven object to be used for shading a number of rays in a compacttimeframe. In some respects, cache 514 can be loaded with these kinds ofdata after a number of rays are collected that intersect an object thatuses such data. For example, a larger set of vertex attributes can befetched and stored in cache 514 for an object intersected by a number ofrays.

FIG. 6 depicts further aspects of an implementation of an intersectiontester (e.g., intersection testing 210). As described with respect toFIG. 4, a number of intersection testers 405 a-405 n can be provided.Each of the testers can interface with a respective buffer 421 a-421 n.The buffers can contain ray identifiers and information about objects tobe intersection tested with rays identified by the ray identifiers. Theray identifiers can be provided from a ready packet list 612 that iscontrolled (via control 631) from a packet unit 608. Ready packet list612 can contain a list of ray identifiers to be tested for intersectionagainst one or more shapes identified in the packet (either by referenceor by included data). Abstraction point 620 receives such a packet fromready packet list 612 and splits the ray identifiers among the buffers421 a-421 n based on which local memories 231 a-231 n contain definitiondata for each of the identified rays. In some implementations,abstraction point 620 can split the data based on correlating rayidentifiers with memory address locations in local memories 231 a-231 n,such as by masking certain bits of each ray identifier in order toidentify the intersection tester with ray definition data for thatparticular ray (of course, more than one local memory may store data fora given ray). Packets can reference elements of acceleration data orprimitives to be intersection tested, and typically, rays are referencedfirst in packets to test against acceleration elements, and ultimately,primitives are identified to be tested.

Packet unit 608 communicates through another abstraction point 605,using system interface 616, to receive further rays to be packetized andintersection tested. Packet unit 608 also can interface with DRAM 618 inorder to schedule memory transactions to deliver shape data tointersection testers based on references included with packets in readylist 612.

Packet unit 608 can use collection memory 606 in maintaining collectionsof ray identifiers against shapes in the acceleration structure, and insome cases, collection memory 606 can be subdivided into fixed sizelocations that can be used to store a given number of ray identifiers.Given that collection memory 606 can have a known or otherwisediscoverable or configurable size, a known number of collections can beaccommodated, and referenced. References to each such location can thusbe maintained in a free location list 610. When results are read fromresults list 614, packet unit 608 processes those results intocollections associated with each acceleration structure elementintersected. Such processing can include retrieving an identifier foreach of the acceleration elements from a return packet, or otherinformation provided by one or more of intersection testers 405 a-405 n.In some implementations, intersection testers 405 a-405 n can pass apacket to collect ray intersection results for a given accelerationelement amongst themselves, and in other examples, each intersectiontester can aggregate test results for a number of acceleration elementsand a ray, or for a ray and a number of acceleration elements.

Thus, intersection testing results get propagated through abstractionpoint 620 to results list 614, while rays of other collectionsidentified in ready packet list 612 are distributed among buffers 421a-421 n. Each intersection tester 405 a-405 n can be operable to readfrom its buffer when it is able to test another ray for intersection. Insome examples, each entry of each buffer can identify a ray to be testedfor intersection with an identified shape. As disclosed with respect toFIG. 4, data for the shape can be provided from a DRAM, and theprovision of such data can be initiated by packet unit 608.

FIG. 7 depicts an example format of a packet 705 that can be stored inready packet list 612, and includes components of a packet ID, aposition, a plurality of ray identifiers and a shape identifier. Theshape identifier preferably identifies a shape that was determined to beintersected by each ray of packet 705, where each identified ray is thento be tested against objects identified as related to the intersectedshape (e.g., child nodes in a hierarchy of acceleration data).

When it is determined that packet 705 is to begin intersection testing,a separate packet can be formed for each object identified based on theidentified shape, and each such packet can be provided to each ofbuffers 421 a-421 n. In other examples, data defining the objects to betested can be provided to intersection testers 405 a-405 n, each ofthose objects can be identified as needing to be tested by theidentified provided in the packet (e.g., a number of bits of theidentifiers can remain the same, such that so long as a certain numberof the bits match, such as the most significant bits, then a givenobject can be identified as a child of another object).

It was described with respect to FIG. 6 and elsewhere (e.g., FIG. 4)that packet unit 608, or another entity managing collection data caninitiate provision of shape data to testers, when it is determined totest an identified group of rays with such shapes. FIG. 8 depicts anexample composition of intersection testers 405 a-405 n in which aworking memory 810 can operate to receive and store such shape data.Working memory 810 can cache such shape data for repeated tests withdifferent rays, such as when a given packet identified two or more raysthat were stored as ray definition data in memory for one tester (seediscussion with respect to FIG. 4, above).

The storage of such shape data can be used in implementing furtheraspects relating to using ray identifiers for triggering ray testingamongst dispersed intersection testers, as described below.

FIG. 8 illustrates an example of a test cell 405 a, which may contain aworking memory 810 and test logic 820. Working memory 810 may be severalregisters, which contain information sufficient to test a line segmentfor intersection with a surface, or may be more complicated in otherimplementations. For example, working memory 810 may store instructionsfor configuring test logic 820 to test a particular shape received forintersection and may detect what shape was received based on the datareceived. Working memory 810 also may cache detected hits, where eachtest cell is configured for testing a series of rays against geometricshapes, or vice versa; then, the cached hits may be output as a group,as further described below. Working memory may also receive incomingshape data from storage, e.g., main memory (205), and store it forusage, such as in implementations according to the examples presentedwith respect to FIGS. 10A and 10B.

However, further explanation concerning how results can be processed isfirst described with respect to FIG. 9. FIG. 9 depicts a packet format901 comprising a packet identifier, a ray identifier (Rid) and one ormore shape hit bits. Packet format 902 depicts a packet ID, anacceleration tree position indicator (position), a ray identifier (rid)and a plurality of shape identifiers and respective indications ofhit/miss information for each ray identifier.

If a packet format for presenting results that is in accordance withformat 901, then an optional lookup (903) of shapes associated with apacket ID can be implemented. For example, when packet in ready list 612is determined to begin testing, the shape indicated in that packet canbe used to identify a plurality of related (e.g., child) shapes, andwhen those related shapes are identified, identifying information forthem can be retained by packet unit 608 or by another functional unit.Then, when results return in a format like that of packet format 901,that repository can be indexed in order to identify the related shapes.

Alternatively, if the shapes are explicitly identified, such as by aformat like that of format 902, then lookup (903) can be skipped. Ineither case, a plurality of shape identifiers (905) are obtained. Eachcan be hashed (910) and a number of bits from the hash value can be usedto index collection memory 606 to identify a plurality of candidatelocations for a ray collection associated with that shape ID. Forexample, collection memory 606 can be implemented a multi-wayinterleaved cache, and the indexing thus can provide multiple candidatelocations for a collection associated with given hash value. Then, anentirety of the shape ID can be compared (917) with a shape ID stored ineach candidate location to determine if the location stores a collectionfor that shape ID. If there is a matching shape ID, then it isdetermined whether the collection has a free slot (919), and if so thenthe rid ID from the packet is added to that location. This example isfor collections with fixed sized, which is a preferred implementation,but collections also can be variably sized.

If there is not a free slot, then one of the collections identified asbeing in one of the matching locations is evicted (922), and acollection for the shape ID is created at the just-evicted, now free,location.

If there was no match (918), then it is determined whether any of thecandidate locations is open (923), and if so then a collection isstarted (924) at that location. If there is no free location, then acollection is evicted (922) and a collection started for the new shapeID at that location. Thus, in some exemplary aspects, collection memory606 can be managed in fixed size chunks where collections can be storedin a subset of available collection locations, based on hash values ofidentifiers for them. An eviction strategy can be implemented to ensurethat a shape will be able to have rays collected against it. Theeviction can result in collection identifying information being placedin ready list 612.

In some implementations, the eviction strategy can be tailored forachieving a variety of objectives that can be relevant intracing/traversing rays in a scene. For example, an override mode 925can be implemented in which one or more differing collection selectionstrategies (926) can be employed. Examples of such strategies areprovided below. The override mode can be engaged at certain times or inresponse to certain conditions. In other examples, there need not be anexplicit decision to change collection selection modes, and instead aset of collection heuristics can be employed that comprehend theobjectives sought to be achieved in both the override and normal modes.Aspects of FIGS. 10A, 10B and FIG. 11 can bear on collection selectionstrategy, and therefore are addressed first.

FIG. 10A depicts a packet flow format in which timeslots T1 . . . T5 areavailable. New ray packets 1001 in this example can identify up to 40rays in each timeslot, while the intersection testing resources can testup to 32 rays in each timeslot, as depicted by ray testing 1005. FIG.10A depicts a situation where a series of completely full packets1002-1005 are provided for testing over timeslots T1-T4. Since thecompletely full packets contain 40 rays, intersection testing of 4 40ray packets requires 5 timeslots. Thus, in timeslot 5, no new rays beginintersection testing.

With deeper buffers at an input to intersection testing (e.g., buffers421 a-421 n), more ray packets can be received before intersectiontesting must begin to catch up. However, in other implementations, it isexpected that the excess of ray identifier transmission capability toray intersection testing capacity is to be used primarily to allowtransmission of non-full collections, while keeping intersection testingresources saturated. Transmission of non-full collections, whilemaintaining saturation allows implementing of collectionselection/eviction strategies that can be dynamic during intersectiontesting progress.

Of note is that FIG. 10A is depicted from the perspective of abstractionpoint 620, such that the packets are provided through abstraction point620, but packet unit 608 does not have visibility to what rays weretested or not, or to which intersection tester each ray of a givencollection was distributed.

Such an example is depicted in FIG. 10B, wherein the same 5 timeslotsare depicted. In T1, a 40 ray packet is transmitted, and 32 rays aretested, leaving 8 untested. FIG. 10B further illustrates that a 32 raypacket can be received in the T2 timeslot, while 32 rays are tested.Thus, of the 40 rays available for testing, 32 can be tested, leaving 8.In T3, a 24 ray packet is received, making 32 rays available for test,all of which can be tested in T3. In T4 and T5, 40 ray packets arereceived, while 32 rays are tested in each timeslot, such that 16 rayscan be left over for testing in subsequent timeslots. In practice,buffering can be deeper that what was described here, such that even ifsome mostly empty packets were received, the buffers for each test cell(see e.g., FIG. 6) would have enough ray identifiers to test.

FIG. 11 depicts further exemplary details of intersection tester 820(FIG. 8). In the depicted example, intersection tester 820 may comprisea plurality of testers 1102 a-1102 n, each having access to workingmemory 810, and which stores data defining a plurality of shapes 825,826, and 833. These shapes were stored in working memory 810 as a resultof a memory fetch initiated by packet unit 608. Buffer 421 a stores rayidentifiers that have been received from a plurality of packets thatwere distributed through abstraint point 620. FIG. 11 depicts furtherthat rays identified by a selection of such ray identifiers are loadedinto respective testers 1102 a-1102 n from ray definition data storage231 a. As depicted, different of testers 1102 a-1102 n can test raysfrom different packets against different shapes.

In some cases, each tester 1102 a-1102 n can be implemented as a threadexecuting on a computation unit. Although each tester 1102 a-1102 n cantest different rays against different shapes, the shapes and raysavailable for test in any of tester 1102 a-1102 n preferably is based onwhether a given intersection tester (e.g., 405 a-405 n) has localizedaccess to definition data for a particular ray. Further, since thatparticular ray is associated through collections with objects to betested for intersection, both the ray identifiers and the shapesavailable in the testers is determined ultimately by packet unit 608. Bycontrast, a number of computation units executing freely on workscheduled independently would be accessing main memory in a more randompattern and with less efficiency.

As explained above, architectures according to the example of FIG. 4 orFIG. 6 can allow asynchronous control of when rays are presented forintersection testing, such that locality of object data against whichthe rays will be tested is substantially increased. it can be the casein intersection testing that packets can often be filled as theseexample architectures provide for deferral of intersection testing forrays, and in such cases, object data often can be streamed from mainmemory, as a large number of rays can be tested against a large numberof objects. However, it can be desirable at times to schedule testing ofpackets that are less full.

For example, intersection testers can be designed to use collectionstorage of a given size, implying that either a maximum or approximatemaximum of collections can be stored at a given time, or that a maximumnumber of active collections can be maintained in a faster memory, forexample. As explained, rays can be collected against elements of anacceleration structure (e.g., a hierarchical structure). In someimplementations, at each point in such a structure, there can be arelatively high fan out. For example, a given node in the structure canhave 8, 10, 16, 24 or even 32 child nodes that are to be tested next forintersection. In turn, each of those nodes can have their own childnodes. Although it is generally desirable to disperse rays into a numberof different collections, in order to increase ray diversity andidentify more rays that can be tested against a common object (e.g., anacceleration element), such dispersal also can cause creation of toomany collections that each need to be tracked.

More concretely and with reference to FIG. 12, it can be assumed that anumber of rays are tested for intersection against children of a rootnode (identified as nodes 1.0-1.n), where node 1.0 is shown connected byedge 1202 to the root node, and similarly, edge 1203 connects node 1.nto the root node. FIG. 12 depicts also that acceleration structures canbe heterogeneous, such that elements bounding primitives directly can besiblings with other elements (e.g., element 1244). Closer to the rootnode, it is often the case that nodes will fan out more widely, asillustrated that node 1.0 a has child nodes p.1-p.n, while node 1.n haschild nodes q.1-q.n (there can be a number of intermediate connectingnodes). Eventually, acceleration structure 1200 narrows closer to nodesthat bound primitives.

In this example, object nodes 1210 are provided, which each boundprimitives that define a respective mesh associated with a differentscene object (e.g., node r.1 can bound primitives associated with oneobject, while node r.2 can bound primitives associated with a differentobject). In turn, further acceleration elements can bound subsets ofprimitives of a given object (e.g, leaf 1 of node r.1), until finallyleaf nodes are reached, which directly bound such primitives (e.g., leafnodes 1-T).

In such an acceleration structure, it may be desirable to control whichcollections are tested for intersection in order to control a number ofnew collections that need to be formed as a result of such testing(avoidance of the explained exponent collection growth). In one example,such control can be effected by selecting collections for intersectionthat are closer to leaf nodes, even if they are less full thancollections nearer the root node. It was explained that some packetformats can contain information about what where in the accelerationstructure the object(s) with which they are associated are located. Insome cases, this information can be a bounce count determined from raysaccumulated in that collection. In other examples, this information caninclude object identifier information, where the object identifier canbe numbered so that the number has meaning within the accelerationstructure. Then, the numbers can be used in determining position in theacceleration structure, and hence whether a collection associatedtherewith has rays closer to test completion.

Thus, by selecting for test collections closer to completion, theintersection testing unit can control a degree of fan out duringtraversal of the tree, and encourage completion and freeing ofcollection space in memory. Since packets can oversupply theintersection testing unit, selection of less-than-full packets can occurwhile intersection testing still is completely saturated.

FIG. 13 depicts method aspects for implementing such an approach to raytracing. FIG. 13 depicts that intersection indication processing 1302communicates with collection readiness processing 1303. Intersectionindication processing 1302 handles returning indications ofintersections of rays and acceleration elements, and can be implemented,for example, in packet unit 608. Exemplary aspects of such processingalso were explained with respect to FIG. 9, and include that raysindicated as having intersected an acceleration element are distributedamong collections of ray identifiers. Collection readiness processing1303 includes that status of the collections can be monitored 1304, suchas by gathering statistics concerning memory usage, and/or fullness ofthe collections individually and/or in the aggregate. A decision can bemade about whether the collection memory is constrained 1305, and in theabsence of determining a constraint condition, collection selection 1306for testing can occur based primarily on collection fullness (althoughthere is no requirement that such decisions be made exclusively on thatbasis). Where a constraint condition was detected, collection can occurbased also on which collections are closer to completion of traversal,which can include in some examples that the collections are closer toleaf nodes, or to another position in an acceleration structure ofinterest.

Then, any such identified or otherwise selected collections can beevicted or flagged as ready for test, and in the example of FIG. 8, canbe stored in ready list 812.

FIG. 14 depicts a aspects of a method that includes ray traversal, raysorting, and preparation for shading. FIG. 14 depicts that rays can betraversed through an acceleration structure (e.g., that of FIG. 12).FIG. 14 also depicts that in one implementation, rays of collections(s)can be intersection tested by a bounding element (e.g., a leaf node)that can be considered as completing the traversal. Such an element canbe a leaf node, or can be another node in the acceleration structure(e.g., a node bounding primitives associated with an object). In eithercase, the rays can be sorted based on a current possible closestdetected intersection for that ray and the object containing thatpossible closest detected intersection. The sorting can provide forsorting ray intersection information, including identifiers forintersecting rays, based on an expectation that certain of the rays willuse one or more of common shading code and common shading data duringshading of their intersections. Such an expectation can be formed inways such as determining that rays have intersected the same primitive,or have intersected different primitives of the same scene object.

It is to be noted that since this description comprises an approachwherein the traversal is stopped before final primitive intersectiontesting, the closest intersection is indicated as possible, since it canbe the case that the ray ultimately may miss intersecting a primitivebounded by an acceleration element, even though it intersects thatelement.

In 1406, a sorting criteria can be determined. In one example, suchsorting criteria includes using an identifier associated with eachprimitive. In another example, such sorting criteria can include that acommon shader, or a portion of a shader code module, and more generally,common data to be accessed and/or code are to be used and/or executed inshading the intersections. The sorting criteria can then be used insorting the intersections. A function 1432 of using a ray identifier tolookup a primitive intersected by the ray (Triangle IDentifier (TID))can also be employed, such that a datapath between ray intersectiontesting and sorting logic can be provided for ray identifiers, and amemory lookup function can be provided to obtain intersectioninformation for identified rays, when required. The lookup can be madefrom ray definition data storage 211, which can be distributed among aplurality of intersection test areas (see e.g., FIG. 6).

In either case, sorting (1407) of intersections (or possibleintersections) into object-associated buffers can be made based on theintersected information then-available (actual and/or possibleintersections), and can be implemented by a sorter. Buffers 1408, 1410,and 1412 are depicted as example buffers for receiving intersectioninformation sorted by object; such buffers can be implemented as FIFOs,ring buffers, linked lists, and so on. Other implementations can sortrays into buffers based on association with a particular code segment,such as a shader. In some implementations, sorting 1407 of rays intobuffers associated with a particular shader or a particular object canbe implemented using ray tracing deferral aspects described above. Insome cases, primitives can each be given a unique number, some portionof which identifies a scene object to which the primitive belongs, andthe sorting of the rays into various of the buffers can be based on aprimitive identifier associated with the ray, or the sceneobject-identifying portion thereof.

A buffer selection 1418 can control from which buffer ray intersectioninformation is obtained for conducting shading operations. Bufferselection 1418 can operate by selecting a fuller or fullest buffer fromamong buffers 1408, 1410, and 1412. In some cases, buffer selection 1418can select any buffer having more than a minimum number of rayscollected therein (collecting rays preferably refers to collectingidentifiers for the rays, but also can include collecting definitiondata for the rays in the buffers). In some examples, a ray result lookupfunction 1430 can be provided for implementations where buffers1408-1412 store ray identifiers, but not all data that would be used toidentify a particular intersection, such as a primitive identifier.

In one example, rays can be collected by object, and shader codeassociated with that object can be loaded 1420, and stored, such as incache 1419. Shaders further can load (1422) definition data for raysidentified in the data read from the selected buffer(s). Vertexattribute data for the object(s) associated with rays from a selectedbuffer can be paged (1424) from memory. Further during execution shadercode loaded for the object can sample texture and other data useful inshading of ray intersections. The collections maintained in buffers1408, 1410, 1412 can be larger, and in some cases much larger thancollections maintained with respect to nodes of the accelerationstructure. For example, each buffer can hold 256, 512, 1024, 1096, 2048,or more or fewer ray intersection indications.

Buffering approaches can include including buffer segments of acomparatively small size, such as 128 entries and linking them as neededfor a larger buffer. Still further approaches can include having aplurality of buffer sizes, and selecting a buffer size based on a numberof primitives composing a shape to be associated with the buffer. Forexample, a shape associated with 250k primitives can be associated witha smaller buffer than a 1M primitive shape. Buffer sizes can be createdbased on an analysis of the scene and the objects composing it. Forexample, if the scene has a distribution of many smaller objects, thanmore smaller buffers can be allocated; conversely, if there are fewerlarger objects in the scene, then fewer larger buffers can be allocated.

Although a buffered approach was described above, aspects of ray sortingand collection described herein do not require such buffering. Forexample, groupings of ray information for which intersections have beendetermined can be outputted immediately after intersection testing,without an intermediate buffering. For example, in some cases,intersection testing resources can concurrently test 32, 64 or more raysfor intersection with selections of primitives that can be related to,or part of, the same scene object. Any rays found to intersect from thatconcurrently testing can be outputted as a group, without buffering,such as buffering to await more rays intersecting the same object. Inother implementations, buffering can be used to aggregate hundreds oreven thousands of rays for outputting to shading.

In some cases, system implementations can include a software or hardwareimplemented function that allows a lookup of what triangle wasintersected by a given ray. For implementations that provide such afunction, the buffers need not store the triangle identifier with theray or ray identifier, and instead, a lookup can be conducted using theray identifier when the ray is ready to be shaded.

In the above aspects, it is preferred to page in a relatively largesection of vertex attributes and maintain that data in cache while anumber of ray intersections are shaded using portions of the paged-invertex data (and other data).

The figure above depicts both functional elements of methods andstructural elements of systems according to the description. Forexample, the testing 1404 can be implemented by structure and systemsaccording to the examples of FIGS. 2-5.

FIG. 15 depicts further examples of how ray collections can be groupedbased on object intersection information, or at a more granular levelbased on portions of shader code being executed. FIG. 15 depictsintersection processing resources 202 that can comprise a plurality ofexecution cores (threads) 1510 a-1510 n, an intersection shadingscheduler 1507, and a cache hierarchy 1515 that can comprise a pluralityof cache memories. In this example, cache hierarchy 1515 can comprise aplurality of caches located on-chip, and/or within a module in whichexecution cores 1510 a-1510 n are located. Further memories 1517 can beaccessed off-chip. Intersection processing resources 202 can executeshader code in execution cores 1510 a-1510 n, and in this particularexample, shader instances 1520 a and 1520 b are depicted, which aredifferences instances of the same shader. Shader instance 1521 is alsodepicted as an instance of shader code for a different shader.

Scheduler 1507 can create points of aggregation at which rays can becollected to defer their shading in favor of shading collections ofother rays. Collection point 1522 depicts a logical view that shadingscheduler 1507 can aggregate rays to await execution of the two depictedshader instances 1520 a and 1520 b (depicts an entrance point of suchshader code). Thus, as rays are deferred, they are collection into acollection associated with collection point 1522. When the collectedrays are to be shaded, data useful in their shading can be paged intocache hierarchy 1515 (as explained with respect to FIG. 14).

FIG. 15 also depicts that shaders may comprise multiple sections ofcode, and may also branch and call other modules of code. For example,code 1525 is depicted as code that was branched to during execution ofshader instance 1520 a, but not shader instance 1520 b. Modules 1531 and1532 are examples of modules, such as a diffuse lighting modules thatcan be called by shaders. A collection point can be provided byscheduler 1507 to collect rays of shader instances that have made callsto such modules. For example, collection point 1530 representscollecting rays that have called module 1532.

As depicted, such calls can come from instances of different shader code(here, instance 1520 b and instance 1521). Once module 1532 has beenexecuted for rays collected at collection point 1530, shaders continuein their normal shading path. For example, rays collected from module1532 can return to execute code 1535, and call module 1536, aftercompletion of module 1532. Similarly, shader instance 1520 a had twotaken branches in which module 1531 is executed for some rays whilemodule 1532 was executed for other rays. Collection point 1530 appliedonly to module 1532, such that for those intersections that took themodule 1531 branch, they would execute code 1533, and ultimatelyconverge to the same code path at module 1537, as would thoseintersections that took module 1532, executed code 1534 beforeconverging at module 1537. FIG. 15 is only exemplary at scheduler 1507can provide a variety of collection points, within shader modules, basedon calls to provided modules, based on access to defined regions ofmemory that have been loaded with object data for certain objects orobject portions, and so on. In one preferred aspect, ray intersectionprocessing can be collected at a start of diffuse lighting calculations,such that diffuse lighting calculations can proceed for a number of raysthat intersected portions of the same object, and in other examples,rays that intersected portions of the same or different object, andwhose shaders use a diffuse lighting call can be collected.

The above examples explained sorting responsive to detection ofintersections with primitives (one example). In addition to sortingbased on detected intersections, each ray also can be associated with adefault bin or buffer in which it is to be sorted, absent a detectedintersection. The specified bin or buffer can be a bin or buffer thatalso is associated with one or more primitives, or objects, orparticular code modules, such that some rays end up there by virtue oftheir respective default assignment, while others end up there as aresult of detecting an intersection that causes that ray to be binned orbuffered there. Therefore, although the prototypical example issorting/buffering/binning based on detected intersections, examples alsocan provide functionality that allows each ray to specify a default. AnAPI call allowing ray emission can be made to accept that defaultassignment.

Combinations of approaches to both examples can be implemented withinone system. A system example in which such aspects can be implemented indepicted in FIG. 16.

By way of further summary, systems according to these examples can morebroadly operate to allocate resources between driving intersectiontesting into further areas of a scene structure, and to produce a widervariety of rays and to starting new camera rays. Ultimately, it isexpected to test all rays emitted by the shaders that execute, but anorder of execution can have important effects on memory usage duringrendering.

Any of the functions, features, and other logic described herein can beimplemented with a variety of computing resources. Examples of computingresource(s) include a thread, a core, a processor, a group ofprocessors, a virtual machine, a fixed function processing element, andthe like. Thus, various approaches, aspects of methods, processingcomponents, and the like were described, and such computing resourcescan provide means for implementing these functions. Also, otherfunctions that may be used in implementing embodiments can be providedor implemented as a process, thread or task that can be localized to onecomputing resource or distributed among a plurality of computingresources (e.g., a plurality of threads distributed among a plurality ofphysical compute resources).

By particular example, computing resources being used for intersectiontest can also host other processes, such as shading processes that areused to shade intersections detected. By further example, if a core cansupport multiple threads, then a thread can be dedicated to shadingwhile another thread can be dedicated to intersection processing.

As discussed above, the described examples can be used in transforming a3-D scene into a 2-D representation of it, as viewed from a definedvantage point. The 3-D scene can include data representations ofphysical objects. Other results of ray intersection testing can includeobject visibility determinations, which can be used in a variety ofapplications. Other transformations include transforming computerreadable media into a different state by storing data determinedaccording to the defined methods.

The above workflow and method examples in preparation for rendering andthe rendering itself can be performed in a system 1600 that may comprisea plurality of computing resources 1604-1607. Computing resources1604-1607 may comprise any one or more of a plurality of processingcores, processors, that can each comprise fixed function and/orprogrammable elements. The computing resources 1604-1607 may alsocomprise different threads of computation on a multi-threaded processor,for example. Each of computing resource 1604-1607 may have read andwrite access to a respective L1 cache 1625 a-1625 n, that can beintegrated with its computation resource or separate. A plurality of L2caches, e.g., L2 cache 1630 and L2 cache 1635, can be provided and canbe shared among the computation resources or private. A shared L3 cacheand/or a main working memory 1640 can be provided. In this example, raydata 1610 and shape data 1615 can be stored in L3/main memory 1640. Theexample system 1600 can execute one or more applications and the scenebuilder workflow, e.g., application/builder 865. The computationresources can communicate with each other over a shared bus 1601, orusing point to point connections, or through shared memory space in theL2 caches 1630 and 1635 or L3/main memory 1640.

In one application, these systems and methods can be used in renderingrepresentations of a 3-D scene for use in holographic imaging systems.In an example approach to rendering for holographic imaging systems, aplurality of images of a given scene are to be rendered, each from adifferent perspective. In rendering such images, each perspective can beconsidered to be an origin of rays to be intersection tested. The raysof each perspective can be collected together for intersection testing,such as collecting rays of different origins and their progeny together,without regard to their origins, but rather with respect to commonalityof intersection testing and/or shading to be performed. Allowingcollection of rays from a plurality of such origins allows systems andmethods to provide for setup of the 3-D scene once, so that such scenesetup is amortized over a large number of image renderings. Also,combining rays to be traced from different origins may allow for greatercoherence and overall processor utilization. Thus, in the aboveexamples, where collections of rays are formed, outputted, or otherwisehandled according to the disclosures, these rays can be attributed to aplurality of camera positions. For example, rays of a given collectioncan be tested against child nodes of a parent node of a commonacceleration structure.

Another application of these disclosures comprises determining mappingsbetween data elements of a first type, which can be defined duringexecution of a computer-implemented process to data elements of a secondtype, which comprise code modules that can use information provided inelements of the first type during execution of the process. In otherwords, as between a number of discrete potential inputs to a number ofdiscrete potential code modules, an application comprises determining,based on characteristics of the potential inputs and characteristics ofthe code modules, which code module is to receive which input. In suchapplications, code modules can generate further potential inputs, forwhich the determination is to be conducted again. Thus, in some suchapplications, a complete dataset to be processed is developed orotherwise evolved during execution of the application itself.

By way of contrast, some classes of processes may have an entirety ofpossible actions to be taken specified prior to initiating the process;for example, code modules that accept data elements used as inputs inthe code modules can be specified prior to execution of a program orprocess that uses the code modules. However, in the presentcircumstances, which actions are to be taken (or code modules executed,in a more specific instance), and under what circumstances those actionsare to be taken, may be indeterminate prior to initiation of the processor even at any given point during the execution of the process. Insteadsuch information is determined during iterations of process execution.As such, in some examples, an entirety of the data set used duringexecution of a process may be indeterminate at commencement of theprocess. Also, it may be indeterminate which code modules (or functionalmodules) of the process will use which portions of the data set. A finegrained parallelization of execution of such processes at compile timeis difficult, because the order of execution of code modules, and whichcode modules may use which inputs is unknown at that time.

Therefore, systems and methods that can determine and scheduleprocessing for portions of a data set that evolves over the course ofexecution of a process to take increased advantage of availableparallelism are desirable. In one particular process category, there canbe one type of data element, where different instances of that dataelement can have different parameters, and each parameter can havedifferent values. Different data elements can have different parameters,even if there is a superset of parameters from which the parametersassociated with any given data element can be chosen.

These data elements can be used as input to code modules that may useparameters of these data elements as inputs, and can also instantiatenew data elements as outputs of execution. When data elements areinstantiated, they are to be closed either by determining that theycause no further code executed, or an appropriate portion of code to berun for each of them is identified (and executed, depending on how theclosure is defined).

A preliminary setup for executing the process includes establishing ann-dimensional space in which code portions (e.g., code modules orportions of a module) can be inter-related or organized by associatingthe code portions with one or more points or locations in then-dimensional spatial structure (such code portions also can beassociated with defined regions in n-dimensional space, but preferably,they are associated with points, and the description uses this example,without limitation).

The n-dimensional space can be sub-divided by an acceleration structurecomprising a plurality of elements, where each of the elementsestablishes a hypersurface (for convenience, called a surface—as in a3-D structure) that bounds a respective selection of points associatedwith respective code portions. In some examples, the accelerationstructure is hierarchical, with child elements of parent elements (thisexample will be used below, for ease of description, but hierarchy inthe acceleration structure is not required). Typically, parentacceleration elements bound supersets of the points bounded by theirchildren, but do not necessarily bound the entirety of the surfaces ofthe child elements themselves.

A plurality of data elements are defined (or obtained), for whichprocessing may need to be conducted. A search in the n-dimensional spaceis to be conducted to determine one or more code modules that are to berun for closing processing of those data elements (and in some moregeneral cases, whether any processing is to be done for a givenelement). The search is to be conducted based on criteria specified inthe data element, which comprise one or more parameters whosepermissible range of values define a path or region in the n-dimensionalspace. For example, in the case of rays as data elements, parameters cancomprise an origin and direction specified in 3-D space, which define aline in 3-D space. Similarly, parameters may define a 3-D object, suchas a sphere. An arbitrary path of a point through space, or of anextrusion of a 2-D surface are other examples. Hyperdimensional regionscan be defined by regular or irregular bounds in the n-dimensionalspace. The region can be contiguous or non-contiguous, e.g., the regionmay comprise a union of a plurality of disjoint portions ofn-dimensional space. Thus, a data element defines a spatial extent inthe n-dimensional space, where n can be two or more; the spatial extentdepends on the parameters and values of the parameters defined for agiven data element (“spatial” is used here for increased understanding,and without limitation as to a number of dimensions in the operationalspace).

To determine what code portion(s) (if any) are to be run for a givendata element, the spatial extent for that data element is tested forintersection in the n-dimensional space with surfaces (hypersurfaces)defined by elements of the acceleration structure. As data elements arefound to intersect surfaces of acceleration elements, those dataelements are collected into collections associated with thoseacceleration elements.

The searching can be done in a computation resource that comprises aplurality of test elements, such as threads, or dedicated test cells,that can test different data elements for intersection with a givensurface (one example). This computation resource is limited in that itcannot concurrently perform all intersection testing that must be done,so this computation resource is to be scheduled. The allocation of thecomputation resource for the testing is based on scheduling collectionsof data elements for further testing, from a pool of collections. Ratherthan testing the data elements in an order in which they were defined orbegan testing, the data elements are tested based on membership incollections selected from the pool. Data elements can concurrently existin multiple collections, and can be tested by virtue of membership inone collection, even while testing based on membership in a differentcollection is deferred.

The deferral of some collections in favor of other collections providesfor further collections to be traversed to join collections in theacceleration structure that have less full collections, such that, ingeneral, data elements from fuller collections can be testedconcurrently (heuristics for collection scheduling can include selectingcollections having other characteristics in some circumstances). In thecase of a hierarchical acceleration structure, a collection of dataelements would be tested next with children acceleration elements of theacceleration element to which the given collection of data elements wasassociated.

In the case of ray intersection testing, the interesting resulttypically is a closest intersection from an origin of the ray beingtested. However, for a more general case of intersection testing ofspatial extents defined by a parametric definition in a data element (inn-dimensional space), a plurality of results can be returned, or aselected result, or an ordering of results. As such, the results to bereturned, and a format thereof, can be specified by provision of aformat to which a data element query can be formatted.

Outputs from such testing can include indications of which data elementsare to be used as inputs to (or triggers to execute) to which codeportions. Such data elements also can be outputted as a collection, suchthat a number of the instances of the same or related code portions canbe provided for different of the data elements. In turn, outputs of thecode portions can include further data elements for which the describedsearching is to be conducted.

In addition or separate from the above, scheduling of execution of thecode portions themselves can include parallelizing the execution of thecode portions for different of the data elements, such that commonportions of the code can execute concurrently for different of the dataelements. Also, other data (e.g, data other than what may be includedwithin the data elements themselves) used by the code portions can beretrieved and cached for use.

Thus, systems according to the above examples can implement methodswhere data elements comprising a plurality of parameters whose valuesdefine a region in an n-dimensional space can be tested for intersectionwith hypersurfaces that bound points (or regions) in space which areassociated with modules of code for execution. The data elements foundto intersect such hypersurfaces can carry data which can be used asinput to one or more of the code modules bounded by an intersectedsurface. In some examples, system can perform further testing toestablish a nearness or intersection to a specified degree of precisionbetween the region defined by a given data element and a pointassociated with a given code module. Testing of a plurality of dataelements preferably is performed concurrently in systems by deferringfurther testing of individual data elements to accumulate a number ofdata elements found to intersect a given hypersurface and schedulingother accumulated data elements for testing on provided systemresources.

Computer code and associated data can be provided for implementingmethods and other aspects described herein. The computer code cancomprise computer executable instructions that may be, for example,binaries, intermediate format instructions such as assembly language,firmware, or source code. The code may configure or otherwise cause tobe configured a general purpose computer, a special purpose computer, ora special purpose processing device to perform a certain function orgroup of functions.

Any such code can be stored in computer readable media, such assolid-state drives, hard drives, CD-ROMs and other optical storagemeans, transiently in volatile memories, such as DRAM, or lesstransiently in SRAM.

A variety of implementations can be provided which can includeinteroperative hardware, firmware and/or software that can also beembodied in any of a variety of form factors and devices, includinglaptops, smart phones, small form factor personal computers, personaldigital assistants, and so on. Functionality described herein also canbe embodied in peripherals or add-in cards. Such functionality also canbe implemented on a circuit board among different chips or differentprocesses executing in a single device, by way of further example.

For example, machines for according to these examples can compriseintersection testing resources including particular fixed-purposetesting cells, and/or general purpose computers configured with computerreadable instructions from a computer readable medium to perform theparticular intersection tests described and interpret the results of thetests. Further machine components include communication links forproviding the acceleration structures to the testing resources and toreceive the results of the testing. The machines for intersectiontesting can be a component of a larger system including other input andoutput devices, such as a drive for reading scene description data, anda display or a computer readable medium for outputting rendered scenes.For example, the computer readable medium can be a DVD and each scenemay be a frame of a motion picture.

In all of the above examples, the 3-D scene being rendered can representan abstraction or a model of a real-world scene and the rays beingtested also can represent light energy being emitted from lights locatedin the scene. Similarly, the usage of the camera also can represent avantage point of an observer for the scene. The output of intersectiontesting results in determining how light affects the scene andultimately affects output that can be consumed by other applications,can be stored in computer readable media, and can be displayed to auser.

Although a variety of examples and other information was used to explainaspects within the scope of the appended claims, no limitation of theclaims should be implied based on particular features or arrangements insuch examples, as one of ordinary skill would be able to use theseexamples to derive a wide variety of implementations. Further andalthough some subject matter may have been described in languagespecific to examples of structural features and/or method steps, it isto be understood that the subject matter defined in the appended claimsis not necessarily limited to these described features or acts. Forexample, such functionality can be distributed differently or performedin components other than, additional to, or less than, those identifiedherein. Rather, the described features and steps are disclosed asexamples of components of systems and methods within the scope of theappended claims.

What is claimed is
 1. A method of performing intersection testing aspart of rendering a 3-D scene by ray tracing in a computer system, themethod comprising: providing a plurality of testing resources with shapedata for a particular shape associated with a 3-D scene; and performingintersection testing for a collection of rays with the particular shape,concurrently, using the plurality of testing resources; wherein thecollection of rays comprises first rays, for which intersection testingagainst the shape is required in order to render a first image of the3-D scene from a first perspective, and second rays for whichintersection testing against the shape is required in order to render asecond image of the 3-D scene from a second perspective.
 2. The methodof claim 1 wherein the particular shape associated with a 3-D scene isone of a triangle, a triangle strip, a vertex, a bounding sphere, anaxis aligned bounding box or a k-d tree definition.
 3. The method ofclaim 1, further comprising collecting together the collection of raysfrom the first and second perspectives with respect to commonality ofintersection testing with the particular shape.
 4. The method of claim 1wherein each of the first and second perspectives acts as an origin forat least some of the rays, and wherein the rays are processed withoutregard to their origins.
 5. The method of claim 1 wherein theperspectives are attributed to a plurality of camera positions.
 6. Themethod of claim 1 wherein the shape data comprises one or more of: (i)primitive data defining primitives in the 3-D scene, and (ii) elementsof an acceleration structure each identifying respective selections ofthe primitives.
 7. The method of claim 1 wherein the rays are defined byone or more shader modules, wherein a shader module can be invoked foreach pixel element within an output buffer.
 8. The method of claim 7,further comprising providing a shader invocation with informationregarding each perspective.
 9. A 3-D graphics processing systemconfigured to perform intersection testing as part of rendering a 3-Dscene by ray tracing in a computer system, comprising: an inputconfigured to receive shape data for a particular shape associated witha 3-D scene; and a plurality of testing resources configured toconcurrently perform intersection testing for a collection of rays withthe particular shape; wherein the collection of rays comprises firstrays, for which intersection testing against the shape is required inorder to render a first image of the 3-D scene from a first perspective,and second rays for which intersection testing against the shape isrequired in order to render a second image of the 3-D scene from asecond perspective.
 10. The system of claim 9 wherein the particularshape associated with a 3-D scene is one of a triangles, a trianglestrip, a vertex, a bounding sphere, an axis aligned bounding box or or ak-d tree definition.
 11. The system of claim 9, further comprising acollection controller configured to collect together rays of the firstand second perspectives and to pass the collection of rays to theplurality of testing resources for processing.
 12. The system of claim 9wherein the plurality of testing resources are configured to applyshading by executing shading operations defined by portions of shadercode, wherein portions of shader code are capable of branching.
 13. Thesystem of claim 12, further comprising a collection controllerconfigured to collect together rays of the first and second perspectivesat collection points defined based on branching within the portions ofshader code.
 14. The system of claim 9, further comprising an outputbuffer configured to store results of processing performed by theplurality of testing resources.
 15. The system of claim 9 wherein one ormore of the plurality of testing resources comprises a respectiveworking memory which comprises registers configured to store data foruse in ray tracing operations performed by that testing resource. 16.The system of claim 9, further comprising one or more shader moduleswhich can be invoked for each pixel element within an output buffer. 17.The system of claim 16, further comprising a memory configured toreceive ray data defining rays to be tested for intersection in the 3-Dscene, the one or more shader modules being configured to define therays and to pass the ray data defining the rays to the memory. 18.Apparatus for performing intersection testing as part of rendering a 3-Dscene by ray tracing in a computer system, the apparatus comprising: aninput configured to receive shape data for a particular shape associatedwith a 3-D scene; and a plurality of testing resources configured toconcurrently perform intersection testing for a collection of rays withthe particular shape; wherein the collection of rays comprises firstrays, for which intersection testing against the shape is required inorder to render a first image of the 3-D scene from a first perspective,and second rays for which intersection testing against the shape isrequired in order to render a second image of the 3-D scene from asecond perspective.
 19. The apparatus of claim 18, further comprising acollection controller configured to collect together rays of the firstand second perspectives and to pass the collection of rays to theplurality of testing resources for processing.
 20. The apparatus ofclaim 19 wherein the collection controller is configured to collect raysfrom the first and second perspectives together with respect tocommonality of intersection testing with the particular shape.